/**
 * Created by lenovo on 19/6/6 006.
 */

var totop = document.querySelector("#totop");
//判断距离顶部的距离，如果大于1000就显示返回顶部否则就不显示
window.onscroll = function(){
/*
    console.log(document.documentElement.scrollTop);
*/
    if(document.documentElement.scrollTop > 1000){
        totop.style.display = 'block';
    }else{
        totop.style.display = 'none';
    }
};
//点击事件，返回顶部
totop.addEventListener('click',function(){
    /*window.scrollTo(0,0);*/
   window.scrollTo({
       top:0,
       behavior:'smooth'
   })
});